package com.summer.shopping.domain.table;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.summer.shopping.enums.bag.BagGoodsStatusEnums;
import lombok.Builder;
import lombok.Data;

/**
 * @TableName bag
 */
@TableName(value ="bag")
@Data
@Builder
public class Bag implements Serializable {
    @TableId
    private Long id;

    private Long userId;

    private Long goodsId;

    private LocalDateTime expireTime;

    private LocalDateTime createTime;

    private Integer status;

    private String type;

    private static final long serialVersionUID = 1L;

    public static Bag getBag(Long userId,Long goodsId,LocalDateTime expireTime,String bagGoodsTypeConstant,Integer num){
        return Bag.builder()
                .userId(userId)
                .goodsId(goodsId)
                .expireTime(expireTime)
                .createTime(LocalDateTime.now())
                .status(BagGoodsStatusEnums.USEFUL.getStatus())
                .type(bagGoodsTypeConstant)
                .build();
    }

    public static Bag getBagOfOneItem(Long userId,Long goodsId,LocalDateTime expireTime,String bagGoodsTypeConstant){
        return getBag(userId,goodsId,expireTime,bagGoodsTypeConstant,1);
    }




    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Bag other = (Bag) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
                && (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getStatus() == null? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
                && (this.getType() == null? other.getType() == null : this.getType().equals(other.getType()))
                && (this.getUserId() == null? other.getUserId() == null : this.getUserId().equals(other.getUserId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getStatus() == null)? 0 : getStatus().hashCode());
        result = prime * result + ((getType() == null)? 0 : getType().hashCode());
        result = prime * result + ((getUserId() == null)? 0 : getUserId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", goodsId=").append(goodsId);
        sb.append(", expireTime=").append(expireTime);
        sb.append(", createTime=").append(createTime);
        sb.append(", isDeleted=").append(status);
        sb.append(", type=").append(type);
        sb.append(", userId=").append(userId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}